package org.asg.dis.model;

import jakarta.persistence.*;
import lombok.Data;

import java.util.Set;

@Entity(name = "roles")
@Data
public class Role {
    @Id
    private Integer id;
    private String name;

    //修改为eager
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "role_permissions",
            joinColumns = @JoinColumn(name = "role_id"),
            inverseJoinColumns = @JoinColumn(name = "permission_id"))
    private Set<Permission> permissions;

    //
    @ManyToMany(mappedBy = "roles")
    private Set<User> users;
}

